/*************************************************************************************
*Copyright (c) 2011, Intel Mobile Communications GmbH. 
*All rights reserved.
*
*Redistribution and use in source and binary forms, with or without
*modification, are permitted provided that the following conditions are met:
*    * Redistributions of source code must retain the above copyright
*      notice, this list of conditions and the following disclaimer.
*    * Redistributions in binary form must reproduce the above copyright
*      notice, this list of conditions and the following disclaimer in the
*      documentation and/or other materials provided with the distribution.
*    * Neither the name of the <organization> nor the
*      names of its contributors may be used to endorse or promote products
*      derived from this software without specific prior written permission.
*
*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
*ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
*WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
*DISCLAIMED. IN NO EVENT SHALL INTEL MOBILE COMMUNICATIONS GMBH. BE LIABLE FOR ANY
*DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
*ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
*(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************/



#include "cef_link.h"
using namespace std;
cef_link::cef_link()
{
	source=NULL;
	destination=NULL;
	id=0;
	name="";
	src_clk=false;
	src_rst=false;
	length=0;
	aux_fw=0;
	aux_bw=0;
	blocks_on_link=NULL;
}
cef_link::cef_link(std::string n,unsigned i,unsigned s,unsigned d,bool clk,bool rst,double l,unsigned af,unsigned ab,std::vector<unsigned>* b)
{
	name=n;
	source=s;
	destination=d;
	id=i;
	src_clk=clk;
	src_rst=rst;
	length=l;
	aux_fw=af;
	aux_bw=ab;
	blocks_on_link=b;
}
cef_link::~cef_link()
{
	if(blocks_on_link) delete blocks_on_link;
}
//Setters
void cef_link::setName(string n)
{
	name=n;
}
void cef_link::setSrc(unsigned s)
{
	source=s;
}
void cef_link::setDst(unsigned d)
{
	destination=d;
}
void cef_link::setAuxF(unsigned f)
{
	aux_fw=f;
}
void cef_link::setAuxB(unsigned b)
{
	aux_bw=b;
}
void cef_link::setID(unsigned i)
{
	id=i;
}
void cef_link::setSrcClk(bool c)
{
	src_clk=c;
}
void cef_link::setSrcRst(bool r)
{
	src_rst=r;
}
void cef_link::setLength(double l)
{
	length=l;
}
void cef_link::setBlocks(vector<unsigned>* b)
{
	blocks_on_link=b;
}
//Getters
string cef_link::getName()
{
	return name;
}
unsigned cef_link::getSrc()
{
	return source;
}
unsigned cef_link::getDst()
{
	return destination;
}
unsigned cef_link::getAuxF()
{
	return aux_fw;
}
unsigned cef_link::getAuxB()
{
	return aux_bw;
}
unsigned cef_link::getID()
{
	return id;
}	
bool cef_link::getSrcClk()
{
	return  src_clk;
}
bool cef_link::getSrcRst()
{
	return src_rst;
}
double cef_link::getLength()
{
	return length;
}
vector<unsigned>* cef_link::getBlocks()
{
	return blocks_on_link;
}
#ifdef _DEBUG
void cef_link::print()
{
	cout<<"CEF Link\nBEGIN\n";	
	cout<<"Name: "<<name<<" Source: "<<source<<" Destination: "<<destination<<" ID: "<<id<<" SrcClk: "<<src_clk<<" SrcRst: "<<src_rst<<" Length: "<<length<<" Aux Fwd: "<<aux_fw<<" Aux Bckwd: "<<aux_bw<<endl;
	if(blocks_on_link)
	{
		cout<<"Blocks on link: ";
		for(unsigned i=0;i<blocks_on_link->size();i++)
		{
			cout<<(*blocks_on_link)[i]<<" ";
		}
		cout<<endl;
	}
	cout<<"END\n";
}
#endif	
